﻿#include "../head/Customer.hh"
#include "../head/Bank.hh"
#include <iostream>

// Customer 构造函数
Customer::Customer(std::string customer_name, std::string savingsAccountID, std::string checkAccountID) : name(customer_name) {
    savingsAccount = new SavingsAccount(savingsAccountID, 0, name);
    checkingAccount = new CheckingAccount(checkAccountID, 0, name);  // 创建支票账户
}

Customer::~Customer() {
    delete checkingAccount;
    delete savingsAccount;
}

CheckingAccount* Customer::getCheckingAccount() const {
    return checkingAccount;
}

SavingsAccount* Customer::getSavingsAccount() const {
    return savingsAccount;
}

std::string Customer::getName() const {
    return name;
}

std::vector<std::string> Customer::getTransactions() const {
    std::vector<std::string> allTransactions;
    const auto& checkingTransactions = checkingAccount->getTransactions();
    const auto& savingsTransactions = savingsAccount->getTransactions();

    // 合并两种账户的交易记录
    allTransactions.insert(allTransactions.end(), checkingTransactions.begin(), checkingTransactions.end());
    allTransactions.insert(allTransactions.end(), savingsTransactions.begin(), savingsTransactions.end());

    return allTransactions;
}